﻿Public Class frm_busquedaEmpleado

    Private Sub rbt_id_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbt_id.CheckedChanged
        txt_nombre.Enabled = False
        txt_id.Enabled = True
        txt_id.Focus()
    End Sub


    Private Sub rbt_nombre_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbt_nombre.CheckedChanged
        txt_id.Enabled = False
        txt_nombre.Enabled = True
        txt_nombre.Focus()
    End Sub


    Private Sub cmd_buscar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_buscar.Click
        If rbt_id.Checked = True Then
            If IsNumeric(txt_id.Text) Then
                frm_empleados.buscarPorId(txt_id.Text)
            Else
                MessageBox.Show("Ingrese un ID", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If
        ElseIf rbt_nombre.Checked = True Then
            If txt_nombre.Text <> "" Then
                frm_empleados.buscarPorNombre(txt_nombre.Text)
            Else
                MessageBox.Show("Ingrese un nombre", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If
        Else
            MessageBox.Show("Seleccione una opción de busqueda", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If

            Me.Close()
    End Sub


    Private Sub cmd_cancelar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_cancelar.Click
        Me.Close()
    End Sub


    Private Sub frm_busquedaEmpleado_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        txt_nombre.Text = ""
        txt_id.Text = ""
        rbt_nombre.Checked = True
    End Sub
End Class